import UIKit

import SnapKit

@objcMembers
public class IMHLoginPopView: CATBaseTipView {
    // UIImageView
    private lazy var vBustImageView: UIImageView = {
        let unaligned = UIImageView()
        unaligned.image = .caTimagePath("")
        return unaligned
    }()

    // UIButton
    private lazy var kPolymorphicBtn: UIButton = {
        let glow = UIButton(type: .custom)
        glow.layer.cornerRadius = 12
        glow.layer.masksToBounds = true
        glow.setTitle("Top UP Now".localized(), for: .normal)
        glow.setTitleColor(.white, for: .normal)
        glow.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
        glow.addTarget(self, action: #selector(vhfkOnPayVipClick(sender:)), for: .touchUpInside)
        return glow
    }()

    // UILabel
    private lazy var oSyncLabel: UILabel = {
        let hoodie = UILabel()
        hoodie.text = "Become a member and view all visitors".localized()
        hoodie.textColor = UIColor(red: 131.0 / 255.0, green: 130.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0)
        hoodie.font = .systemFont(ofSize: 14, weight: .regular)
        hoodie.numberOfLines = 2
        hoodie.textAlignment = .center
        return hoodie
    }()

    // UILabel
    private lazy var hWingLabel: UILabel = {
        let rambutan = UILabel()
        rambutan.text = "Who just visited me?".localized()
        rambutan.textColor = UIColor(red: 49.0 / 255.0, green: 48.0 / 255.0, blue: 51.0 / 255.0, alpha: 1.0)
        rambutan.font = .systemFont(ofSize: 16, weight: .semibold)
        return rambutan
    }()

    // UIButton
    private lazy var fRunningBtn: UIButton = {
        let supersets = UIButton(type: .custom)
        supersets.addTarget(self, action: #selector(vhfkOnCloseClick(sender:)), for: .touchUpInside)
        supersets.setImage(.caTimagePath(""), for: .normal)
        return supersets
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        configSubpixelPitayaViews()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        configSubpixelPitayaViews()
    }

    private func configSubpixelPitayaViews() {
        // UI组件初始化
        /// UIImageView
        vhbsView.addSubview(vBustImageView)
        vBustImageView.snp.makeConstraints { make in
            make.top.equalTo(0)
            make.leading.equalTo(0)
            make.trailing.equalTo(-0)
            make.bottom.equalTo(-0)
        }

        /// UIButton
        vhbsView.addSubview(kPolymorphicBtn)
        kPolymorphicBtn.snp.makeConstraints { make in
            make.leading.equalTo(24)
            make.trailing.equalTo(-24)
            make.bottom.equalTo(-16)
            make.height.equalTo(48)
        }

        /// UILabel
        vhbsView.addSubview(oSyncLabel)
        oSyncLabel.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.trailing.equalTo(-16)
            make.bottom.equalTo(-24)
        }

        /// UILabel
        vhbsView.addSubview(hWingLabel)
        hWingLabel.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.trailing.equalTo(-16)
            make.bottom.equalTo(-16)
            make.height.equalTo(20)
        }

        /// UIButton
        vhbsView.addSubview(fRunningBtn)
        fRunningBtn.snp.makeConstraints { make in
            make.top.equalTo(12)
            make.trailing.equalTo(-12)
            make.width.equalTo(24)
            make.height.equalTo(24)
        }
    }

    @objc func vhfkOnPayVipClick(sender _: UIButton) {
        // 处理点击事件
    }

    @objc func vhfkOnCloseClick(sender _: UIButton) {
        // 处理点击事件
    }

    public class func vhdyView(vhdyV: UIView?) -> IMHLoginPopView! {
        IMHLoginPopView.vhbsRemove(String(describing: IMHLoginPopView.self))
        let vhbsview = IMHLoginPopView(frame: CGRect(x: 0, y: 0, width: VHbsWidth, height: VHbsHeigth))
        if vhdyV != nil {
            vhdyV!.addSubview(vhbsview)
        } else {
            vhbsWindow()?.addSubview(vhbsview)
        }
        return vhbsview
    }
}
